home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Developer / SAT / Collision ƒ / Collision.p < prev    next >
Encoding:
Text File  |  1994-07-26  |  1.2 KB  |  52 lines  |  [TEXT/PJMM]

  1. {*****************************}
  2. {********* SAT Collision **********}
  3. {*****************************}
  4.  
  5. {A SAT demo that is slightly over SATminimal, demonstrating the simplest}
  6. {collision handling based on the kind field (KindCollision).}
  7.  
  8. program SATcollision;
  9.  
  10.     uses
  11.         SAT, sMrEgghead, sApple;
  12.  
  13.     var
  14.         ignoreSp: SpritePtr;
  15.         l: longint;
  16.         p: Point;
  17. begin
  18. {Standard Inits are done by Think Pascal.}
  19.  
  20. {Initialize SAT}
  21.     ConfigureSAT(true, kVPositionSort, kKindCollision, 32);
  22.     InitSAT(128, 129, 512, 322);
  23.  
  24. {Initialize sprite units}
  25.     initMrEgghead;
  26.     initApple;
  27.  
  28. {Show and update the window}
  29.     ShowWindow(gSAT.wind);
  30.     SelectWindow(gSAT.wind);
  31.     PeekOffscreen;
  32.  
  33. {Make sprites}
  34.     GetMouse(p); {We get the mouse position in order to put Mr Egghead under it immediately}
  35.     ignoreSp := NewSprite(0, p.h, p.v, @SetupMrEgghead);
  36.     ignoreSp := NewSprite(0, 0, Rand(gSAT.offSizeV - 32), @SetupApple);
  37.  
  38.     HideCursor;
  39.  
  40.     repeat
  41.         l := TickCount;
  42.         RunSAT(true); {Run a frame of animation}
  43.         while l > TickCount - 3 do {Speed limit}
  44.             ;
  45.  
  46. {Start a new apple once in a while}
  47.         if Rand(40) = 1 then
  48.             ignoreSp := NewSprite(0, 0, Rand(gSAT.offSizeV - 32), @SetupApple);
  49.     until Button;
  50.     ShowCursor;
  51.     SATSoundShutUp; {Always make sure the sound channel is de-allocated!}
  52. end.